<script type="text/javascript">//<![CDATA[
	  
      var SELECTED_RANGE = null;
      function getSelectionHandler() {
              var startDate = null;
              var ignoreEvent = false;
              return function(cal) {
                      var selectionObject = cal.selection;

                      // avoid recursion, since selectRange triggers onSelect
                      if (ignoreEvent)
                              return;

                      var selectedDate = selectionObject.get();
                      if (startDate == null) {
                              startDate = selectedDate;
                              SELECTED_RANGE = null;
                              //document.getElementById("info").innerHTML = "Click to select end date";
							  //document.getElementById("f_inicio").innerHTML=selectionObject.print("%d-%m-%Y");
							  document.formElem.fecha_inicio.value=selectionObject.print("%Y-%m-%d %H:%M:%S ");		
							 
                              
							  // comment out the following two lines and the ones marked (*) in the else branch
                              // if you wish to allow selection of an older date (will still select range)
                              cal.args.min = Calendar.intToDate(selectedDate);
                              cal.refresh();
                      } else {
                              ignoreEvent = true;
							  //aca inserto
							  document.formElem.fecha_fin.value=selectionObject.print("%Y-%m-%d %H:%M:%S");
                              selectionObject.selectRange(startDate, selectedDate);
                              ignoreEvent = false;
                              SELECTED_RANGE = selectionObject.sel[0];

                              // alert(SELECTED_RANGE.toSource());
                              //
                              // here SELECTED_RANGE contains two integer numbers: start date and end date.
                              // you can get JS Date objects from them using Calendar.intToDate(number)

                              startDate = null;
							  
                              //document.getElementById("info").innerHTML = selectionObject.print("%Y-%m-%d") +
                                //      "<br />Click again to select new start date";

                              // (*)
                              cal.args.min = null;
                              cal.refresh();
                      }
              };
      };

     var cal= Calendar.setup({
              cont          : "cont",
              fdow          : 1,
              selectionType : Calendar.SEL_SINGLE,
              onSelect      : getSelectionHandler(),
			  trigger       : "trigger",
			  showTime: true,
			  inputField : "calendar-inputField"
			  
      });
	  function visible(){
		  cal.hide();
		  }
		  //visible();
    //]]></script>